<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<script type="text/javascript">
djConfig = {
    scopeMap: [
        ["dojo", "coolio"],
        ["dijit", "cooliow"],
        ["dojox", "cooliox"],
    ],
    modulePaths: {
        "coolio.actions": "../coolio/actions"
    },
    bindEncoding: "UTF-8",
    searchIds: []
};
</script>
<script type="text/javascript" src="<%=basePath%>javascript/dojo/dojo/dojo.js"></script>
<script>
coolio.addOnLoad(function() {
		coolio.xhrGet({
		    url: "<%=basePath%>get_process",
		    handleAs: "json",
		    content: {
		    	processId: '<s:property value="#session.processId"/>'
		    },
		    handle:function(data){
		    	var url=window.location.href;
		    	for(var i=0;i<data.length;i++){
		    		var iscurrent=false;
		    		if(url.indexOf(data[i].namespace.substring(1)+'/'+data[i].action+'?')!=-1){
		    			iscurrent=true;
		    			if(i!=data.length-1){
		    				window.onbeforeunload = function() {
		    					return 'Are you sure you want to jump out of the process?';
		    				};
		    			}
		    		}
		    		add_process(data[i].displayName,iscurrent);
		    	}
		    },
		    error: function(response, ioArgs){
		    	alert("xhr get failed:");
		        return response;
		    }
		});
});

function add_process(displayName,iscurrent){
	var span = document.createElement('span');
	span.innerHTML=displayName;
	if(iscurrent){
		span.className="current";
	}
	var processDiv = document.getElementById("process");
	processDiv.appendChild(span);
}
</script>
<style>
#process span a {
	text-decoration:none;
}
#process span {
	background-color: #FFFF00;
	font-size: 14px;
	font-weight: bold;
	height: 30px;
	line-height: 30px;
	width: 120px;
	margin-left: 20px;
	padding: 5px;
}
#process span.current {
	background: #FF0000;
	font-size: 20px;
	font-weight: bold;
	height: 40px;
	line-height: 40px;
	width: 140px;
}
</style>
<div id="process"></div>
<p></p>

